<template>
  <div class="login">
    <!-- 登录表单 -->
	<el-form ref="loginForm" :model="loginForm" class="login-form" autocomplete="on" label-position="left">
		<!--登录信息抬头,可以是图片,可以是文字 -->
		<div class="title-container">
			<h3>微商城后台管理系统</h3>
		</div>
		<el-form-item prop="userType">
			<el-select placeholder="请选择用户类型" name="userType" v-model="loginForm.userType" style="width: 100%;">
				<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
			</el-select>
		</el-form-item>
		<!-- 用户名 -->
		<el-form-item prop="loginName">
			<el-input 
				prefix-icon="el-icon-user" 
				ref="loginName" 
				v-model="loginForm.loginName"
				name="loginName"
				autocomplete="on"
				placeholder="请输入用户名"
				tabindex="1"
			/>
		</el-form-item>
		<!-- 密码 -->
		<el-form-item prop="certificate">
			<el-input 
				prefix-icon="el-icon-lock"
				ref="certificate"
				v-model="loginForm.certificate"
				name="certificate"
				autocomplete="on"
				placeholder="请输入密码"
				tabindex="2"
				show-password
			/>
		</el-form-item>
		<el-button :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleLogin('01')">登录</el-button>
	</el-form>
    <!--  底部  -->
    <div class="el-login-footer">
      <span>Copyright © 2020 90hyscxy.com All Rights Reserved.</span>
    </div>
  </div>
</template>

<script>

export default {
  name: "Login",
  data() {
    return {
      loading: false,
		loginForm: {
			loginName:'',
			logingType:'',
			thirdType:'',
			userType:'system-user',
			certificate:''
		},
		options:[
			{
				label:'管理员',
				value:'system-user'
			}
		]
    };
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect;
      },
      immediate: true
    }
  },
  created() {
  },
  methods: {
    handleLogin(logingType) {
		this.loading = true
		this.loginForm.logingType = logingType
		this.$store.dispatch('Login',this.loginForm).then(() =>{
			this.$router.push({ path: '/' })
		})
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../../assets/image/login-background.jpeg");
  background-size: cover;
}
.title-container {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}

.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: 400px;
  padding: 25px 25px 5px 25px;
  min-height: 380px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.login-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
</style>
